package flc.ast.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.TypeBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class TypeAdapter extends StkProviderMultiAdapter<TypeBean> {

    public TypeAdapter() {
        addItemProvider(new StkSingleSpanProvider(30));
        addItemProvider(new StyleProvider());
    }

    private class StyleProvider extends BaseItemProvider<TypeBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_home_type;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, TypeBean bean) {
            baseViewHolder.setText(R.id.tvHomeTypeItemName, bean.getName());
            if (bean.isSelected()) {
                baseViewHolder.setBackgroundColor(R.id.llHomeTypeItem, Color.parseColor("#027EFA"));
                baseViewHolder.setTextColor(R.id.tvHomeTypeItemName, Color.parseColor("#FBEBCE"));
            } else {
                baseViewHolder.setBackgroundColor(R.id.llHomeTypeItem, Color.parseColor("#242F56"));
                baseViewHolder.setTextColor(R.id.tvHomeTypeItemName, Color.parseColor("#727E96"));
            }
        }
    }
}
